package com.fs.system.college_admin.controller;

import com.fs.system.college_admin.service.ActiveTypeService;
import com.fs.system.common.ResponseData;
import com.fs.system.student.domain.ActType;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/collegeAdminActiveType")
public class ActiveTypeController {

    @Resource
    private ActiveTypeService activeTypeService;

    @PostMapping("/addActiveType")
    public ResponseData addActiveType(@RequestBody ActType actType) {
        activeTypeService.addActiveType(actType);
        return new ResponseData("200", "添加成功");
    }

    @GetMapping("/selectActiveTypeList")
    public ResponseData selectActiveTypeList(ActType actType) {
        List<ActType> activeTypeList = activeTypeService.selectActiveTypeList(actType);
        return new ResponseData("200", "查询成功",activeTypeList);
    }

    @GetMapping("/selectPage")
    public ResponseData selectPage(
            ActType actType,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "5") Integer pageSize
    ) {
        PageInfo<ActType> activeTypePageInfo = activeTypeService.selectPage(actType,pageNum, pageSize);
        return new ResponseData("200", "查询成功",activeTypePageInfo);
    }

    @PutMapping("/updateActiveType")
    public ResponseData updateActiveType(@RequestBody ActType actType) {
        activeTypeService.updateActiveType(actType);
        return new ResponseData("200", "修改成功");
    }
    /**
     * 逻辑删除
     */
    @PutMapping("/deleteActiveType/{typeId}")
    public ResponseData deleteActiveType(@PathVariable Long typeId, @RequestParam String updateBy) {
        activeTypeService.deleteActiveType(typeId, updateBy);
        return new ResponseData("200", "删除成功");
    }

    /**
     * 批量删除
     * @param
     * @return
     */
    @PutMapping("/deleteActiveTypeBatch/{updateBy}")
    public ResponseData deleteBatch(
            @PathVariable String updateBy,
            @RequestBody List<Long> ids
    ){
        System.out.println(ids);
        activeTypeService.deleteBatch(ids,updateBy);
        return new ResponseData("200", "批量删除成功");
    }

}
